<?php
require_once __DIR__.'/common/common.php';
$data=mysqli_query($mysql,"SELECT * FROM `menu` WHERE shangcode=0");
$arr=array();
$arr1=array();
/*while ($a=mysqli_fetch_assoc($data))
{
    $c=$a['code'];
    $arr[$a['data']]=array();
    $data1=mysqli_query($mysql,"SELECT * FROM `menu` WHERE shangcode=$c");
    while ($a1=mysqli_fetch_assoc($data1))
    {
        $arr[$a['data']][]=$a1['data'];
    }
}*/
while ($a=mysqli_fetch_assoc($data))
{
    $c=$a['code'];
    $arr[$a['data']]=array();
    $data1=mysqli_query($mysql,"SELECT * FROM `menu` WHERE shangcode=$c");
    while ($a1=mysqli_fetch_assoc($data1))
    {
        $arr[$a['data']][]=$a1['data'];
    }
}



mysqli_free_result($data);
//var_export($arr);
//var_export($arr1);
echo json_encode(array('a'=>$arr,'a1'=>$arr1));
//echo json_encode($arr);

/*$arr2=array();
foreach ($arr1 as $value)
{
    $data=mysqli_query($mysql,"SELECT * FROM `menu` WHERE shangcode=$value");
    while ($a=mysqli_fetch_assoc($data))
    {
        $arr2[]=$a['data'];
    }
    $arr2[]='一';
}*/

/*$data=mysqli_query($mysql,"SELECT * FROM `menu` WHERE shangcode=1");
while ($a=mysqli_fetch_assoc($data))
{
    $arr2[]=$a['data'];
}*/
//var_export($arr2);

